<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('goods/index')}">商品主页</a></li>
			<li class="active"><a href="{:url('goods/add')}">商品添加</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('goods/addPost')}">
			<div class="form-group">
				<label for="input-author" class="col-sm-2 control-label">商品名称<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-author" name="name">
				</div>
			</div>
			<div class="form-group">
				<label for="input-image" class="col-sm-2 control-label">商品图片</label>
				<div class="col-md-6 col-sm-10">
					<input id="photo-1" type="hidden"  name="image" >
					<input id="photo-1-name" class="form-control" type="text"  name="image" title="商品图片" disabled readonly>
				</div>
			</div>
			<div class="form-group">
				<label for="input-image" class="col-sm-2 control-label"></label>
				<div class="col-md-6 col-sm-10">
					<img id="photo-1-preview" src="" width="40px">
					<a href="javascript:uploadOneImage('图片上传','#photo-1');" class="btn btn-primary">上传</a>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-md-6 col-sm-10">
					<div id = 'imagesContainer'></div>
					<div class="margin-top-10">
					<a class="btn btn-default" href="javascript:uploadMultiImage('图片上传','#imagesContainer','photos-item-wrapper');">选择图片</a>
					</div>
				</div>
			</div>
			<script type="text/html" id="photos-item-wrapper">
				<div style="display: flex;align-items: center;border: 1px solid #ddd;padding: 5px;margin-top: 10px">
					<div><img id="photo-{id}-preview" src="{url}" class="imag-thumbnail" style="width: 100px;height: 50px"></div>
					<div style="margin-left: 10px">图集</div>
					<input id="photo-{id}" type="hidden" name="chart[]" value="{filepath}">
				</div>
			</script>
			<div class="form-group">
				<label class="col-sm-2 control-label">商品出售主题<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<select name="status" class="form-control">
						<option value="0" <eq name="data" value="0">selected</eq>>下架</option>
						<option value="1" <eq name="data" value="1">selected</eq>>正常</option>
						<option value="2" <eq name="data" value="2">selected</eq>>上线</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="input-type" class="col-sm-2 control-label">商品出售主题<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-type" name="title">
				</div>
			</div>
			<div class="form-group">
				<label for="input-Discount" class="col-sm-2 control-label">经营方式<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<select name="switch" class="form-control">
						<option value="0" <eq name="data" value="0">selected</eq>>自营</option>
						<option value="1" <eq name="data" value="1">selected</eq>>旗舰店</option>
						<option value="2" <eq name="data" value="2">selected</eq>>非自营</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="input-Primary" class="col-sm-2 control-label">商品原始价格<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-Primary" name="PrimaryPrice">
				</div>
			</div>
			<div class="form-group">
				<label for="input-Discount" class="col-sm-2 control-label">商品折扣价格<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-Discount" name="DiscountPrice">
				</div>
			</div>
			<div class="form-group">
				<label for="input-code" class="col-sm-2 control-label">购买数量<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="input-code" name="number">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">添加</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
				</div>
			</div>
		</form>
	</div>
	<script>
		function sendSms() {
			let mobile = document.getElementById('input-mobile').value
			$.ajax({
				url: "{:url('goods/sendAliSms')}",
				data: {
					mobile: mobile
				},
				success:function (res){
					if( res.code==0 ){
						alert('验证码发送成功，请查收')
					}else{
						layer.msg(res.msg,{icon:1,time:1500});
					}
				},
				error:function (){
					layer.msg("发送失败",{icon:2,time:1500});
				}
			})
		}
	</script>
	<script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
	<script type="text/javascript">
		//编辑器路径定义
		var editorURL = GV.WEB_ROOT;
	</script>
	<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
	<script type="text/javascript">
		var editorcontent = new baidu.editor.ui.Editor();
		editorcontent.render('input-content');
	</script>
</body>
</html>
